//
//  TXPTableViewCell_word.m
//  StayAwhile
//
//  Created by dllo on 16/1/29.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXPTableViewCell_word.h"


@interface TXPTableViewCell_word ()

@property (nonatomic, retain) UIImageView *headImageView;
@property (nonatomic, retain) UILabel *nameLabel;// 名字
@property (nonatomic, retain) UILabel *timeLabel;// 发布时间
@property (nonatomic, retain) UILabel *wordLabel;// 发布的文字
@end
@implementation TXPTableViewCell_word

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    //    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.left.mas_equalTo (self.myImgView.mas_right).offset(20);
    //        make.top.mas_equalTo (self.mas_top).offset(45);
    //        make.size.mas_equalTo(CGSizeMake(200, 40));
    //
    //    }];
    
    // 头像
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    self.headImageView.backgroundColor = [UIColor lightGrayColor];
    self.headImageView.layer.cornerRadius = 25;
    self.headImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.headImageView];
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (self.mas_top).offset(20);
        make.left.mas_equalTo (self.mas_left).offset(20);
        make.size.mas_equalTo (CGSizeMake(50, 50));
        
    }];
    // 名字
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.textColor = RGBA(78, 101, 147, 1);
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (self.mas_top).offset(35);
        make.left.mas_equalTo (self.headImageView.mas_right).offset(10);
        make.size.mas_equalTo (CGSizeMake(200, 20));
        
    }];
    
    // 发布时间
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.textColor = [UIColor lightGrayColor];
    self.timeLabel.font = [UIFont boldSystemFontOfSize:14];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (self.mas_top).offset(35);
        make.left.mas_equalTo (self.mas_right).offset(- 70);
        make.size.mas_equalTo (CGSizeMake(150, 20));
        
    }];
    
    // 发布的文字
    self.wordLabel = [[UILabel alloc] init];
    self.wordLabel.textColor = RGBA(73, 73, 73, 1);
    self.wordLabel.font = [UIFont boldSystemFontOfSize:15];
    self.wordLabel.numberOfLines = 0;
    [self.contentView addSubview:self.wordLabel];
    [self.wordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo (self.headImageView.mas_bottom).offset(30);
        make.left.mas_equalTo (self.mas_left).offset(20);
        make.right.mas_equalTo (self.mas_right).offset(- 20);
        make.bottom.mas_equalTo (self.mas_bottom).offset(-40);
        
    }];
    
}

- (void)setFraModel:(TXPFragmentModel *)fraModel{
    _fraModel = fraModel;
    NSURL *url = [NSURL URLWithString:_fraModel.model.icon];
    [self.headImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]];
    self.nameLabel.text = _fraModel.model.uname;
    self.timeLabel.text = _fraModel.addtime_f;
    self.wordLabel.text = _fraModel.content;
    [self.wordLabel sizeToFit];
    self.labelHeight = self.wordLabel.frame.size.height + 140;
    
}



@end
